package com.wht.controller.music;

import com.wht.domain.Music;
import com.wht.domain.PageBean;
import com.wht.service.music.FindMusicService;
import com.wht.service.music.impl.FindMusicServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author wanghaotian
 * time:2022/11/21,0021 21:15
 * description:
 */

@WebServlet("/FindAllMusicController")
public class FindAllMusicController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String strPage = req.getParameter("currentPage");
        if(strPage == null){
            strPage = "1";
        }
        FindMusicService findMusicService = new FindMusicServiceImpl();
        PageBean<Music> pageBean = findMusicService.findPageByCurrentPage(Integer.parseInt(strPage),10);
        req.setAttribute("pageBean",pageBean);
        req.getRequestDispatcher("/music/main.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}